<?php

/**
 * @Author: Wang chunsheng  email:2192138785@qq.com
 * @Date:   2023-05-06 19:34:21
 * @Last Modified by:   Wang chunsheng  email:2192138785@qq.com
 * @Last Modified time: 2023-06-06 15:13:03
 */

namespace App\Api;

use Common\ApiController;
use Common\Services\Sys\ProjectService;
use Hyperf\HttpServer\Annotation\AutoController;

#[AutoController(prefix: '{project_sn}/project')]
class ProjectController extends ApiController
{
    public array $signOptional = ['*'];

    /**
     * 项目列表
     * @return array
     * @date 2023-06-06
     * @example
     * @author Wang Chunsheng
     * @since
     */
    public function list(): array
    {
        $request = $this->request;
        $page = $request->input('page') ?? 1;
        $pageSize = $request->input('pageSize') ?? 10;
        $keyWords = $request->input('keyWords') ?? '';

        $Res = ProjectService::listProject($page, $pageSize, $keyWords);

        return $this->writeJson(200, $Res, '获取列表成功');
    }

    /**
     * 项目详情
     * @return array
     * @date 2023-06-06
     * @example
     * @author Wang Chunsheng
     * @since
     */
    public function detail(): array
    {
        $request = $this->request;
        $id = $request->input('id');
        $Res = ProjectService::detailProject($id);

        return $this->writeJson(200, $Res, '获取成功');
    }
}
